<div class="area-wrapper"></div>
<div class="search-wrapper">
    <h5>新增社团</h5>
    <div class="search-box">
        <input type="text" name="startDate" class="start-date" placeholder="年-月-日" readonly /> - <input type="text" name="endDate" class="end-date" placeholder="年-月-日" readonly /><a href="" class="abtn-search">查询</a>
    </div>
    <div class="search-data">
        <table>
            <thead>
                <tr>
                    <td>社团性质</td>
                    <td>新增数</td>
                    <td>累计数</td>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>已挂靠</td>
                    <td class="yes-new"></td>
                    <td class="yes-all"></td>
                </tr>
                <tr>
                    <td>未挂靠</td>
                    <td class="no-new"></td>
                    <td class="no-all"></td>
                </tr>
            </tbody>
            <tfoot>
                <tr>
                    <td>合计</td>
                    <td class="global-new"></td>
                    <td class="global-all"></td>
                </tr>
            </tfoot>
        </table>
    </div>
</div>
<script>
    $(function(){
        $('.area-wrapper').load('/admin/template/home/welcome/area.html')
        $('.start-date,.end-date').datetimepicker({
            minView: "month",
            format: 'yyyy-mm-dd',
            language: 'zh',
            autoclose: 1,
            maxDate: new Date()
        })
        //$('.end-date').datetimepicker({format: 'yyyy-mm-dd'})
        $('.abtn-search').on('click', function(){
            var startDate = $('.start-date').val(), endDate = $('.end-date').val(), selectedCode = sessionStorage.getItem("selectedCode") || null
            if(startDate >= endDate){
                alert("起始日期必须小于结束日期")
                return
            }
            $.ajax({
                url : "/admin/statistics/groupCount",
                data: JSON.stringify({
                    startDate: startDate,
                    endDate: endDate,
                    jurisdiction: selectedCode
                }),
                headers: {
                    'content-type': 'application/json'
                },
                dataType:'json',
                type:'post',
                success:function(data){
                    $('.yes-new').html(data.data.yesNew)
                    $('.yes-all').html(data.data.yesAll)
                    $('.no-new').html(data.data.noNew)
                    $('.no-all').html(data.data.noAll)
                    $('.global-new').html(parseInt(data.data.yesNew)+parseInt(data.data.noNew))
                    $('.global-all').html(parseInt(data.data.yesAll)+parseInt(data.data.noAll))
                }
            })
            return false
        })
    })
</script>